/**
 * Created by fangshufeng on 2018/4/22.
 */
import React from 'react';
import {connect} from 'react-redux'
import {
    withRouter,
    Redirect
} from 'react-router-dom'

class GlobalRouter extends React.Component {

    render() {
        // console.log(this.props);
        const {current_env_tag} = this.props;
        const {pathname} = this.props.location;
        const path = ['/mockTool/dashboard','/mockTool/envSelect','/mockTool/bindDevice'];
        if (path.includes(pathname)) {
            return null;
        }
        if (current_env_tag === '') {
            return <Redirect to={path[1]}/>
        } else {
            return <Redirect to={path[0]}/>
        }
    }
}

export default withRouter(connect(state => state.app, null)(GlobalRouter));